package com.shopx.cm.controller;

import lombok.extern.slf4j.Slf4j;
import com.shopx.base.anno.ShopxParamAnno;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.shopx.base.controller.BaseController;
import javax.annotation.Resource;
import com.shopx.cmm.DTO.PageDTO;
import com.shopx.base.dto.Result;
import com.shopx.base.utils.ResultUtil;
import com.shopx.base.exception.ShopxException;
import com.shopx.cm.bean.CmSync;
import com.shopx.cm.model.CmSyncModel;
import com.shopx.cm.service.ICmSyncService;

import com.shopx.base.anno.RepearSubmitChkAnno;
import com.shopx.core.common.CommonConstant;

/**
 * TODO
 * @author lituo
 * @className: CmSyncController
 * @date 2025-01-07
 */
@RestController
@Slf4j
@RequestMapping(value = "/cmSync")
public class CmSyncController extends BaseController{

	@Resource
    private ICmSyncService cmSyncService;

	@PostMapping(value = "/queryPageList")
@ShopxParamAnno
 public Result<PageDTO> queryPageList(@RequestBody CmSyncModel cmSync) throws ShopxException{
		PageDTO<CmSyncModel> pageDTO = cmSyncService.getListPage(cmSync);
  		return ResultUtil.ok(pageDTO);
	}

	@PostMapping(value = "/insertOne")
	@RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
		@ShopxParamAnno
public Result<Integer> insertOne(@RequestBody CmSync cmSync) throws ShopxException {
		int result = cmSyncService.insertSelective(cmSync);
      	return ResultUtil.ok(result);
	}

	@PostMapping(value = "/updateOne")
	@RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
			@ShopxParamAnno
public Result<Integer> updateOne(@RequestBody CmSync cmSync) throws ShopxException {
		int result = cmSyncService.updateByPrimaryKeySelective(cmSync);
        return ResultUtil.ok(result);
	}

	@PostMapping(value = "/queryOneByPrimaryKey")
				public Result<CmSyncModel> queryOneByPrimaryKey(@RequestBody CmSync cmSync) throws ShopxException {
		CmSyncModel result = cmSyncService.selectByPrimaryKey(cmSync);
		return ResultUtil.ok(result);
	}

	/*@PostMapping(value = "/deleteChecked")
	@RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
					@ShopxParamAnno
public Result<Integer> deleteChecked(@RequestBody CmSync cmSync) throws ShopxException {
		int result = cmSyncService.deleteByPrimaryKey(cmSync);
		return ResultUtil.ok(result);
	}*/
}

